﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;

public partial class Reg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (eSYSU.Business.UserService.IsLogin())
                Response.Redirect("Member/UserCenter.aspx");
        }
    }

    //
    protected void submit_Click(object sender, EventArgs e)
    {
        if (tb_Password.Text.Trim() == tb_PWRepeat.Text.Trim() && cb_License.Checked)
        {
            if (tb_VCode.Text.ToLower() == Session["eSYSU_VCODE"].ToString().ToLower())
            {
                DBO dbo = new DBO();

                MySqlParameter[] msp_User = {
                new MySqlParameter("@UserName",MySqlDbType.VarChar,16),
                new MySqlParameter("@Password",MySqlDbType.VarChar,63),
                new MySqlParameter("@Email",MySqlDbType.VarChar,63)
                                        };
                msp_User[0].Value = tb_UserName.Text.Trim().ToLower();
                msp_User[1].Value = eSYSU.Common.StringHelper.MD5(tb_Password.Text);
                msp_User[2].Value = tb_EMail.Text;

                dbo.ExecProcDirectly("proc_AddUser_Basic", msp_User);

                eSYSU.Business.UserService.SetUserLoginSession(tb_UserName.Text.Trim(), 30);

                Panel_Step1.Visible = false;
                Panel_Step2.Visible = true;
            }
            else
            {
                //Response.Write(Session["eSYSU_VCODE"].ToString());
            }
        }
    }
}